package com.test;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

@SpringBootApplication
public class ThreadApplication implements ApplicationListener<ContextRefreshedEvent> {

    /**
     * 日志输出器.
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(ThreadApplication.class);

    public static void main(String[] args) {
        try {
            SpringApplication sa = new SpringApplication(ThreadApplication.class);
            sa.run(args);
        } catch (final Exception e) {
            LOGGER.error("boot up fail :", e);
        }
    }

    @Override
    public void onApplicationEvent(final ContextRefreshedEvent contextRefreshedEvent) {

        // 手工设置pool的大小，便于演示
        System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "4");
    }


}
